<template>
  <view class="module-header">
    <view class="module-name" :style="[moduleNameCss]">{{ moduleName }}</view>
    <view
      class="more"
      :style="[moduleMoreCss]"
      v-if="showMore || propsData.params.moreLink"
      @click="goUrl"
    >
      <span>{{ more }}</span>
      <i class="iconfont icon-arrow-right"></i>
    </view>
  </view>
</template>

<script>
export default {
  props: {
    propsData: {
      type: Object,
      default: () => {
        return {};
      },
    },
    moduleName: {
      type: String,
      default: "",
    },
    moreText: {
      type: String,
      default: "",
    },
    showMore: {
      type: Boolean,
      default: false,
    },
  },

  data() {
    return {
      more: this.$t("common.more"),
    };
  },
  computed: {
    moduleNameCss() {
      let style = this.propsData.params.moduleNameCss;
      if (style?.fontNum) {
        style.fontSize = `${style.fontNum * 2}rpx`;
      }
      return style;
    },
    moduleMoreCss() {
      let style = this.propsData.params.moduleMoreCss;
      if (style?.fontNum) {
        style.fontSize = `${style.fontNum * 2}rpx`;
      }
      return style;
    },
  },
  methods: {
    goUrl() {
      let item = this.propsData.params.moreLink;
      if (item) {
        let { link, open_type } = item;
        this.$utils.toUrl(link, open_type);
      }
    },
  },
  mounted() {
    if (this.moreText) {
      this.more = this.moreText;
    }
  },
};
</script>

<style scoped lang="scss">
.module-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  .module-name {
    font-size: 4.267vw;
    font-weight: 600;
    color: #262626;
    margin-bottom: 0;
  }
  .more {
    display: flex;
    align-items: center;
    font-size: 3.2vw;
    font-weight: 400;
    color: #888888;
    margin-bottom: 0;
    line-height: 4.267vw;
    .iconfont {
      font-size: 2.267vw;
    }
  }
}
</style>
